package com.ctshk.rpc.goods.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.ctshk.rpc.goods.dto.ShoppingSpecialPageDTO;
import com.ctshk.rpc.goods.entity.ShoppingSpecial;
import com.ctshk.rpc.goods.mapper.provider.ShoppingSpecialProvider;
import com.ctshk.rpc.goods.req.ShoppingSpecialPageReq;
import org.apache.ibatis.annotations.SelectProvider;

/**
 * <p>
 * 商城专题 Mapper 接口
 * </p>
 *
 * @author 姜斌文
 * @since 2021-04-30
 */
public interface ShoppingSpecialMapper extends BaseMapper<ShoppingSpecial> {

    @SelectProvider(type = ShoppingSpecialProvider.class, method = "findShoppingSpecialPageByCondition")
//    @Select({
//            "<script>" +
//                    "SELECT\n" +
//                    "t.id,\n" +
//                    "t.special_topics,\n" +
//                    "t.special_picture_url,\n" +
//                    "t.special_title,\n" +
//                    "t.create_id,\n" +
//                    "t.sort,\n" +
//                    "t.is_display,\n" +
//                    "t.gmt_create,\n" +
//                    "( SELECT COUNT( 1 ) FROM t_shopping_special_commodity ssc WHERE ssc.special_id = t.id ) AS 'specialCommodityCount' \n" +
//                    "FROM\n" +
//                    "t_shopping_special t \n" +
//                    "<where>" +
//                    "t.is_deleted = 0" +
//                    "<if test=\"pageReq.specialTitle!=null and pageReq.specialTitle!=''\">and t.special_title like concat('%',#{pageReq.specialTitle},'%')</if> \n" +
//                    "<if test='pageReq.operatorId!=null'>and t.operator_id = #{pageReq.operatorId}</if>" +
//                    "</where> \n" +
//                    "order by t.sort asc, t.gmt_create desc" +
//                    "</script>"
//    })
    IPage<ShoppingSpecialPageDTO> findShoppingSpecialPageByCondition(IPage<ShoppingSpecialPageDTO> page, ShoppingSpecialPageReq pageReq);
}
